package routes

import (
	"goserver/middleware"
	"net/http"

	"go.mongodb.org/mongo-driver/mongo"
)

type RouteConfig struct {
	DB *mongo.Database
}

func setupEntityRoutes[T any](
	routePath string,
	handlerFunc func(http.ResponseWriter, *http.Request),
) {
	http.HandleFunc(routePath, middleware.CheckRequestMiddleware(handlerFunc))
}
func SetupAllRoutes(config RouteConfig) {
	SetupFileRoutes()
	SetupWebsiteRoutes()
	SetupPersonRoutes(config.DB, "person")
	SetupUserRoutes(config.DB, "users")
	SetupTrajectoryRoutes(config.DB, "trajectory")
	SetupTestaRoutes(config.DB, "testa")
	SetupTestRoutes(config.DB, "test")
}
